package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Advertisement;

public class AdvertisementSqlProvider {

    public String insertSelective(Advertisement record) {
        BEGIN();
        INSERT_INTO("st_advertisement");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getAid() != null) {
            VALUES("aid", "#{aid,jdbcType=INTEGER}");
        }
        
        if (record.getTitle() != null) {
            VALUES("title", "#{title,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            VALUES("picture", "#{picture,jdbcType=VARCHAR}");
        }
        
        if (record.getToday_exposure() != null) {
            VALUES("today_exposure", "#{today_exposure,jdbcType=INTEGER}");
        }
        
        if (record.getTotal_exposure() != null) {
            VALUES("total_exposure", "#{total_exposure,jdbcType=INTEGER}");
        }
        
        if (record.getTotal_money() != null) {
            VALUES("total_money", "#{total_money,jdbcType=DOUBLE}");
        }
        
        if (record.getSurplus_money() != null) {
            VALUES("surplus_money", "#{surplus_money,jdbcType=DOUBLE}");
        }
        
        if (record.getMonovalent() != null) {
            VALUES("monovalent", "#{monovalent,jdbcType=DOUBLE}");
        }
        
        if (record.getData_time() != null) {
            VALUES("data_time", "#{data_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getLink() != null) {
            VALUES("link", "#{link,jdbcType=VARCHAR}");
        }
        
        if (record.getContent() != null) {
            VALUES("content", "#{content,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Advertisement record) {
        BEGIN();
        UPDATE("st_advertisement");
        
        if (record.getAid() != null) {
            SET("aid = #{aid,jdbcType=INTEGER}");
        }
        
        if (record.getTitle() != null) {
            SET("title = #{title,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            SET("picture = #{picture,jdbcType=VARCHAR}");
        }
        
        if (record.getToday_exposure() != null) {
            SET("today_exposure = #{today_exposure,jdbcType=INTEGER}");
        }
        
        if (record.getTotal_exposure() != null) {
            SET("total_exposure = #{total_exposure,jdbcType=INTEGER}");
        }
        
        if (record.getTotal_money() != null) {
            SET("total_money = #{total_money,jdbcType=DOUBLE}");
        }
        
        if (record.getSurplus_money() != null) {
            SET("surplus_money = #{surplus_money,jdbcType=DOUBLE}");
        }
        
        if (record.getMonovalent() != null) {
            SET("monovalent = #{monovalent,jdbcType=DOUBLE}");
        }
        
        if (record.getData_time() != null) {
            SET("data_time = #{data_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getLink() != null) {
            SET("link = #{link,jdbcType=VARCHAR}");
        }
        
        if (record.getContent() != null) {
            SET("content = #{content,jdbcType=VARCHAR}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}